import {
    getReservation
} from '@/services/home/home'

Page({
    data: {
        phoneNumber: '13167972555',
        menuList: [{
            name: '全部课程',
            icon: '/assets/images/home/menu-01.png',
            path: '/pages/goods/list/index'
        }, {
            name: '场馆展示',
            icon: '/assets/images/home/menu-02.png',
            path: ''
        }, {
            name: '教练信息',
            icon: '/assets/images/home/menu-04.png',
            path: ''
        }, {
            name: '消息通知',
            icon: '/assets/images/home/menu-03.png',
            path: ''
        }, {
            name: '活动信息',
            icon: '/assets/images/home/menu-03.png',
            path: ''
        }],
        userInfo: null
    },

    onShow() {
        const userInfo = JSON.parse(wx.getStorageSync('userInfo') || '{}')
        if (userInfo && userInfo.customerId) {
            this.setData({
                userInfo: userInfo
            })
            this.queryReservation()
        }
    },

    onLoad() {
        this.init();
    },

    onReachBottom() {},

    onPullDownRefresh() {
        this.init();
    },

    init() {
        wx.stopPullDownRefresh();
        this.setData({
            pageLoading: false,
        });
    },

    queryReservation() {
        const {
            userInfo
        } = this.data
        console.log(userInfo)
        getReservation({
            customerId: userInfo.customerId
        }).then((res) => {
            
        })
    },

    openPosition() {
        wx.showToast({
            title: '地图导航功能正在开发中！',
            icon: 'none'
        })
    },

    openCall() {
        wx.makePhoneCall({
            phoneNumber: this.data.phoneNumber
        });
    },

    toPath(e) {
        const {
            item
        } = e.currentTarget.dataset
        if (item.path) {
            wx.navigateTo({
                url: item.path
            })
        } else {
            wx.showToast({
                title: item.name + '页面正在开发中！',
                icon: 'none'
            })
        }
    },

    onReTry() {},

});